<template >
<div style="background:#fff;">

	<!-- <el-row :gutter="20"> -->
	  	<!-- <el-col :span="24" > -->
	  		<el-card class="box-card">
	  			<div slot="header" >
				    设备登录
				</div>

				<!-- <img src="111" class="image"> -->

			  	<el-form ref="form" :model="form" label-width="80px">
					<el-form-item label="设备号">
						<el-input v-model="form.username"></el-input>
					</el-form-item>

					<el-form-item label="密码">
						<el-input type="password" v-model="form.password"></el-input>
					</el-form-item>

				  	<el-form-item >
				    	<el-button type="primary" @click="gogo" style="width:100%">登录</el-button>
				  	</el-form-item>
				</el-form>
			</el-card>
	  	<!-- </el-col> -->
	<!-- </el-row> -->

</div>
</template>

<script>

import { mapGetters } from 'vuex'
import { setCookie, getCookie} from '../../config/util'

export default {
	
	name : 'destorylogin',
	
	data () {
		return {
		  	form : {
		  		username : '',
		  		password : '',
		  	}
		}
	},

	props : {

	},

	components : {
		
	},

	computed : {
		...mapGetters([
			
		]),
	},

	methods : {
		gogo () {
			let para = {
				fun : 'destroyLogin',
				device : this.form.username,
				password : this.form.password,
				cb : res => {
					console.log(res);

					setCookie('dusername', this.form.username);
					setCookie('dpassword', this.form.password);

					this.$router.push({ 
						'name': 'destroyMain', 
						'params' : {
			    			'name' : res.name,
			    			'devicecode' : this.form.username,
			    		}
					});
				},
				err : res => {
					console.log('error');
					console.log(res);
					this.$message.error(res);
				}
			};

			this.$store.dispatch('update', para);
		},
	},

	watch : {
	    
	},

	mounted () {
		this.form.username = getCookie('dusername');
		this.form.password = getCookie('dpassword');
	},

}
</script>

<style scoped>
.image {
	width: 100%;
}
</style>
